package com.ruoyi.warning.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.warning.domain.entity.SysRoleDevice;
import com.ruoyi.warning.mapper.SysRoleDeviceMapper;
import com.ruoyi.warning.service.ISysRoleDeviceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色和菜单关联表 服务实现类
 * </p>
 *
 * @author chenhc
 * @since 2025-07-28
 */
@Service
public class SysRoleDeviceServiceImpl extends ServiceImpl<SysRoleDeviceMapper, SysRoleDevice> implements ISysRoleDeviceService {

    @Override
    @PreAuthorize("@ss.hasPermi('system:config:export')")
    public Object getList(Long roleId) {
        List<SysRoleDevice> list = this.list(new QueryWrapper<SysRoleDevice>()
                .lambda().eq(SysRoleDevice::getRoleId, roleId));
        List<Long> deviceIds = list.stream().map(SysRoleDevice::getDeviceId).collect(Collectors.toList());
        return deviceIds;
    }
}
